package edu.ccut.saturn.operation;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.Map;

import edu.ccut.saturn.component.SaturnData;
import edu.ccut.saturn.operation.database.DeleteByCondition;
import edu.ccut.saturn.operation.database.DeleteByPrimaryKey;
import edu.ccut.saturn.operation.database.DeleteBySQL;
import edu.ccut.saturn.operation.database.Insert;
import edu.ccut.saturn.operation.database.InsertBySQL;
import edu.ccut.saturn.operation.database.QueryByCondition;
import edu.ccut.saturn.operation.database.QueryByConditionWithPage;
import edu.ccut.saturn.operation.database.QueryByPrimaryKey;
import edu.ccut.saturn.operation.database.QueryBySQL;
import edu.ccut.saturn.operation.database.QueryBySaturnSQL;
import edu.ccut.saturn.operation.database.QueryCountByCondition;
import edu.ccut.saturn.operation.database.QueryCountBySQL;
import edu.ccut.saturn.operation.database.UpdateByCondition;
import edu.ccut.saturn.operation.database.UpdateByPrimaryKey;
import edu.ccut.saturn.operation.database.UpdateBySQL;

public class DataBaseOperation {
	private static DataBaseOperation instance = new DataBaseOperation();
	private DataBaseOperation(){};
	public static DataBaseOperation getInstance(){
		return instance;
	}
    public int deleteByCondition(String fullkey,String condition,Connection conn) throws Exception{
    	return  DeleteByCondition.getInstance().execute(fullkey, condition, conn);
    }
    public int deleteByPrimaryKey(String fullkey,String primaryKeyValue,Connection conn) throws Exception {
    	return  DeleteByPrimaryKey.getInstance().execute(fullkey, primaryKeyValue, conn);
    }
    public int deleteBySQL(String sql,Connection conn) throws Exception {
    	return  DeleteBySQL.getInstance().execute(sql, conn);
    }
    public int insert(SaturnData saturndata,Connection conn) throws Exception {
    	return  Insert.getInstance().execute(saturndata, conn); 
    }
    public int insertBySQL(String sql,Connection conn) throws Exception {
    	return  InsertBySQL.getInstance().execute(sql, conn);
    }
    public ArrayList<SaturnData> queryByCondition(String fullkey, String condition,Connection conn) throws Exception {
    	return  QueryByCondition.getInstance().execute(fullkey, condition, conn);
    }
    public ArrayList<SaturnData> queryByConditionWithPage(String fullkey ,String condition,int startIndex,int endIndex,Connection conn) throws Exception {
    	return  QueryByConditionWithPage.getInstance().execute(fullkey, condition, startIndex, endIndex, conn);
    }
    public SaturnData queryByPrimaryKey(String fullkey ,String primaryKeyValue,Connection conn) throws Exception {
    	return  QueryByPrimaryKey.getInstance().execute(fullkey, primaryKeyValue, conn);
    }
    public ArrayList<SaturnData> queryBySQL(String fullkey ,String sql,Connection conn) throws Exception {
    	return  QueryBySQL.getInstance().execute(fullkey, sql, conn);
    }
    public int queryCountByCondition(String fullkey ,String condition,Connection conn) throws Exception {
    	return  QueryCountByCondition.getInstance().execute(fullkey, condition, conn);
    }
    public int queryCountBySQL(String sql,Connection conn) throws Exception {
    	return  QueryCountBySQL.getInstance().execute(sql, conn);
    }
    public int updateByCondition(SaturnData saturnData ,String condition,String specialcolumn,Connection conn) throws Exception {
    	return  UpdateByCondition.getInstance().execute(saturnData, condition, specialcolumn, conn);
    }
    public int updateByPrimaryKey(SaturnData saturnData,String specialcolumn,Connection conn) throws Exception {
    	return  UpdateByPrimaryKey.getInstance().execute(saturnData, specialcolumn, conn);
    }
    public int updateBySQL(String sql ,Connection conn) throws Exception {
    	return  UpdateBySQL.getInstance().execute(sql, conn);
    }
    public ArrayList<SaturnData> queryBySaturnSql(String  fullkey ,String sqlkey,Map<String,Object> paramMap,Connection conn) throws Exception {
    	return  QueryBySaturnSQL.getInstance().execute(fullkey,sqlkey,paramMap,conn);
    }
}
